package com.yycx.module.bus.provider.handler.haiying.salemanbalance;

import com.yycx.common.base.entity.EntityMap;
import com.yycx.common.constants.CommonConstants;
import com.yycx.common.mybatis.interceptor.SaveInterceptor;
import com.yycx.common.mybatis.query.CriteriaSave;
import com.yycx.common.security.OpenHelper;
import com.yycx.common.utils.OrderNoUtil;
import com.yycx.module.bus.client.entity.BusPayment;
import com.yycx.module.bus.client.enums.AmountTypeEnum;
import com.yycx.module.bus.provider.handler.haiying.BusinessUtils;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 资保金收款保存扩展器
 *
 * @author zyf
 */
@Component
public class HySaleManBalancePaymentSaveHandler implements SaveInterceptor<BusPayment> {

    @Resource
    private BusinessUtils businessUtils;

    @Override
    public void prepare(CriteriaSave cs, EntityMap entityMap, BusPayment payment) {
        Long userId = OpenHelper.getUserId();
        Long companyId = OpenHelper.getCompanyId();
        String paymentNo = businessUtils.getPaymentNo(companyId, userId);
        payment.setPaymentNo(paymentNo);
        payment.setTitle("资保金收款");
        payment.setAmountType(AmountTypeEnum.CustomBond.getCode());
        payment.setOrganizationId(OpenHelper.getOrganizationId());
        payment.setCompanyId(OpenHelper.getCompanyId());
        payment.setUserId(OpenHelper.getUserId());
        payment.setNickName(OpenHelper.getNickName());
        payment.setPaymentState(CommonConstants.INT_0);
    }
}
